package com.qf.controller;

import com.qf.pojo.TCheckitem;
import com.qf.service.TCheckitemService;
import com.qf.utils.Result;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequiredArgsConstructor
public class CheckitemController {
    private final TCheckitemService checkitemService;
    @GetMapping("/checkitem/findPage")
    public Result listCheckitemPage(@RequestParam(value = "currentPage",defaultValue = "1")int page,
                                    @RequestParam(value = "pageSize",defaultValue = "10")int pageSize,
                                    @RequestParam(value = "queryString",defaultValue = "") String queryString){

        return checkitemService.listCheckitemPage(page,pageSize,queryString);
    }

    @PostMapping("/checkitem/add")
    public void add(@RequestBody TCheckitem checkitem){
         checkitemService.add(checkitem);
    }

    @GetMapping("/checkitem/findById")
    //
    public Result findCheckitemById(@RequestParam("id") int id){
        return checkitemService.findById(id);
    }

    @PostMapping("/checkitem/edit")
    public void edit(@RequestBody TCheckitem checkitem){
        checkitemService.updateById(checkitem);
    }

    @PostMapping("/checkitem/delete")
    public void delete(@RequestParam("id") int id){
        checkitemService.removeById(id);
    }


}
